package com.ruoyi.Processor;

import com.ruoyi.common.entity.Project;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

// 列表处理器
class ListProcessor implements ContentProcessor {
    @Override
    public boolean canProcess(Element element) {
        return element.tagName().equals("ol") || element.tagName().equals("ul");
    }
    
    @Override
    public void process(Element element, Project project) {
        StringBuilder listContent = new StringBuilder();
        Elements items = element.select("li");
        
        for (Element item : items) {
            listContent.append("- ").append(item.text()).append("\n");
        }
        
        // 将列表内容添加到描述中或单独存储
        if (project.getIntroDescription() == null) {
            project.setIntroDescription(listContent.toString());
        } else {
            project.setIntroDescription(project.getIntroDescription() + "\n\n" + listContent.toString());
        }
    }
}